package com.lyx.controller;

import com.lyx.response.Result;
import com.lyx.service.OssServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName OssController
 * @Description: TODO
 * @Author 86152
 * @Date 2022/3/15
 * @Version V1.0
 **/
@Api(tags = "oss管理")
@CrossOrigin
@RestController
@RequestMapping("/oss")
public class OssController {
    @Autowired
    private  OssServer ossServer;


    @PostMapping("/createBucket")
    @ApiOperation(value = "创建Bucket")
    public Result createBucket(){

            ossServer.createBucket();

        return Result.ok();
    }

    @PostMapping("/uploadImgFile")
    @ApiOperation(value = "图片上传")
    public Result uploading(MultipartFile file){

        String url = ossServer.uploading(file);

        return Result.ok().data("url",url);
    }





}
